package cn.kent.high.juc.queue;

import java.util.concurrent.PriorityBlockingQueue;

/**
 * PriorityBlockingQueue 带优先级的无界阻塞队列
 * 每次出队都返回优先级最高或最低的元素
 * 内部使用平衡二叉树堆实现->直接遍历不保证有序
 * 默认比较使用compareTo方法，可自定义规则
 */
public class PriorityBlockingQueueTest {
    public static void main(String[] args) {
        PriorityBlockingQueue<String> queue = new PriorityBlockingQueue<>();
        queue.add("hello");
        queue.remove("hello");
        String peek = queue.peek();
        System.out.println(peek);
        boolean isExist = queue.contains("hello");
        System.out.println(isExist);
        queue.offer("hello");

    }
}
